<%--
  Created by IntelliJ IDEA.
  User: Yang
  Date: 2021/11/25
  Time: 11:50
  To change this template use File | Settings | File Templates.
--%><%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%@include file="common/devhead.jsp"%>
<body>
<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>Form validation <small>sub title</small></h2>
                <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="#">Settings 1</a>
                            </li>
                            <li><a href="#">Settings 2</a>
                            </li>
                        </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                </ul>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <form action="${pageContext.request.contextPath}/appInfo/appInfoUpdate" class="form-horizontal form-label-left" novalidate enctype="multipart/form-data" method="post">
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="softwareName">手游名称 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="hidden" value="${appView.id}" name="id">
                            <input  class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" id="softwareName" name="softwareName" placeholder="请输入手游名称"  type="text" value="${appView.softwareName}">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="APKName">APK名称 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="APKName" value="${appView.APKName}" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="APKName" placeholder="请输入APK名称"  readonly="readonly" type="text">
                            <span class="apknameExist"></span>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" >支持ROM <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input  value="${appView.supportROM}" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="supportROM" placeholder="请输入ROM"  type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="interfaceLanguage">界面语言 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="interfaceLanguage" value="${appView.interfaceLanguage}" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="interfaceLanguage" placeholder="请输入手游支持的界面语言"  type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="softwareSize">手游大小 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="softwareSize" value="${appView.softwareSize}" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="softwareSize" placeholder="请输入手游大小、单位为Mb"  type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="downloads">下载次数 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="downloads" value="${appView.downloads}" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="downloads" placeholder="请输入下载次数"  type="text">
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" >所属平台 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <select class="form-control"  name="flatformId" id="flatformId">
                                <option value="0">请选择</option>
                                <c:forEach items="${ddry}" var="dd">
                                    <c:if test="${appView.flatformId==dd.valueId}">
                                        <option value="${dd.valueId}" selected="selected">${dd.valueName}</option>
                                    </c:if>
                                    <c:if test="${appView.status!=dd.valueId}">
                                        <option value="${dd.valueId}">${dd.valueName}</option>
                                    </c:if>

                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="categoryLevel1">一级分类 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="hidden" id="level1" value="${appView.categoryLevel1}">
                            <select class="form-control" name="categoryLevel1" id="categoryLevel1" onchange="fenlei"></select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="categoryLevel2">二级分类 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="hidden" id="level2" value="${appView.categoryLevel2}">
                            <select class="form-control" name="categoryLevel2" id="categoryLevel2" onchange="fenlei"></select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="categoryLevel3">三级分类 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="hidden" id="level3" value="${appView.categoryLevel3}">
                            <select class="form-control" name="categoryLevel3" id="categoryLevel3" onchange="fenlei"></select>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="status">手游状态 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <c:if test="${appView.status==3}">
                                <input  value="审核不通过" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2"   required="required" readonly="readonly" type="text">
                                <input type="hidden" value="1" name="status" id="status"/>
                            </c:if>
                            <c:if test="${appView.status==1}">
                                <input  value="待审核" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2"   required="required" readonly="readonly" type="text">
                                <input type="hidden" value="1" name="status" id="status"/>
                            </c:if>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="appInfo">应用简介 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <textarea id="appInfo"  class="form-control col-md-7 col-xs-12"  name="appInfo"  type="text">${appView.appInfo}</textarea>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">LOGO图片 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="hidden" id="errorinfo" value="${uploadError}">
                            <c:if test="${appView.logoPicPath==null}">
                                <input type="file" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="picPath" id="idPic"/>
                            </c:if>
                            <c:if test="${appView.logoPicPath!=null}">
                                <img class="picc" src="${pageContext.request.contextPath}${appView.logoPicPath}" style="width: 100px;height: 80px;">
                                <input type="hidden" value="${appView.logoPicPath}"name="logoPic">
                                <input type="hidden" value="${appView.logoLocPath}"name="logoLoPic">
                                <input style="display: none" type="file" class="form-control col-md-7 col-xs-12" data-validate-length-range="6" data-validate-words="2" name="picPath" id="idPic"/>
                            </c:if>
                            <a href="javascript:;" class="picdel" id="${appView.id}">删除</a>
                        </div>
                    </div>
                    <div class="ln_solid"></div>
                    <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
                            <c:if test="${appView.status==3}">
                                <button  type="submit" class="btn btn-success">保存再次提交审核</button>
                                <button id="send" type="submit" class="btn btn-success">保存</button>
                                <a href="${pageContext.request.contextPath}/appInfo/devlist" class="btn btn-primary">返回</a>
                            </c:if>
                            <c:if test="${appView.status==1}">
                                <button id="send" onclick="tj()" type="submit" class="btn btn-success">保存</button>
                                <a href="${pageContext.request.contextPath}/appInfo/devlist" class="btn btn-primary">返回</a>
                            </c:if>

                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</div>
</div>
</body>
<%@include file="common/devfoot.jsp"%>
<script src="${pageContext.request.contextPath}/statics/js/jquery-1.12.4.js"></script>
<script src="${pageContext.request.contextPath}/statics/js/update.js"></script>
<script>
    var option=null
    var path='${pageContext.request.contextPath}';
    var backBtn=null;
    $(".picdel").click(function (){
        var id=this.id;
        $.getJSON(path+"/appInfo/delImg/"+id,"",function (data){
            if (data){
                $("[name=picPath]").show()
                $(".picc").remove();
                $(".picdel").hide()
            }else{
                alert("删除失败")
            }
        })
    })
    $(function () {
        backBtn = $("#back");
        backBtn.on("click",function(){
            //alert("view : "+referer);
            if(referer != undefined
                && null != referer
                && "" != referer
                && "null" != referer
                && referer.length > 4){
                window.location.href = referer;
            }else{
                history.back(-1);
            }
        });
        $("#picdel").click(function (){

            $(".picc").hide()
            $("#picdel").hide()
        })
        $.getJSON(path + "/category/fenlei1", '', function (data) {
            option = "<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                if ($("#level1").val() == +data[i].id) {
                    option += "<option selected='selected' value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                } else {
                    option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                }
            }
            $("#categoryLevel1").html(option);
        })
        $.ajax({
            type: "GET",
            url: path + "/category/fenlei2",
            data: {parentId: $("#level1").val()},
            dataType: "json",
            success: function (data) {
                option = "<option value='0'>请选择</option>";
                for (var i = 0; i < data.length; i++) {
                    if ($("#level2").val() == data[i].id) {
                        option += "<option selected='selected' value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                    } else {
                        option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                    }
                }
                $("#categoryLevel2").html(option);
            }
        })
        $.getJSON(path + "/category/fenlei3", {parentId: $("#level2").val()}, function (data) {
            option = "<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                if ($("#level3").val() == +data[i].id) {
                    option += "<option selected='selected' value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                } else {
                    option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                }
            }
            $("#categoryLevel3").html(option);
        })

        $.getJSON(path + "/category/fenlei1", '', function (data) {
            option = "<option value='0'>请选择</option>";
            for (var i = 0; i < data.length; i++) {
                option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
            }

            $("#categoryLevel1]").html(option);
        })

        $("#categoryLevel1").change(function () {
            var categoryLevel1 = $("#categoryLevel1").val();
            if (categoryLevel1 != "" && categoryLevel1 != null) {
                $.ajax({
                    type: "GET",
                    url: path + "/category/fenlei2",
                    data: {parentId: categoryLevel1},
                    dataType: "json",
                    success: function (data) {
                        option = "<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                        }
                        $("#categoryLevel2").html(option);

                    },
                    error: function (data) {
                        alert("加载二级菜单失败")
                    }
                })
            } else {
                $("#categoryLevel2").html("");

                option = "<option value='0'>请选择</option>";
                $("#categoryLevel2").html(option);

            }
            $("#categoryLevel3").html("");

            option = "<option value='0'>请选择</option>";
            $("#categoryLevel3").html(option);

        })
        $("#categoryLevel2").change(function () {
            var categoryLevel2 = $("#categoryLevel2").val();
            if (categoryLevel2 != "" && categoryLevel2 != null) {
                $.ajax({
                    type: "GET",
                    url: path + "/category/fenlei3",
                    data: {parentId: categoryLevel2},
                    dataType: "json",
                    success: function (data) {
                        option = "<option value='0'>请选择</option>";
                        for (var i = 0; i < data.length; i++) {
                            option += "<option value='" + data[i].id + "'>" + data[i].categoryName + "</option>"
                        }

                        $("#categoryLevel3").html(option);
                    },
                    error: function (data) {
                        alert("加载三级菜单失败")
                    }
                })
            }
        })
    })
</script>
</html>
